package com.project.controller;

import com.project.bean.FacilityBean;
import com.project.bean.RoomBean;
import com.project.dao.IFacilityDao;
import com.project.service.IFacilityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("facility")
public class FacilityController {
    @Autowired
    private IFacilityService facilityService;

    @RequestMapping("add")
    public String add(FacilityBean facilityBean, Integer roomId) {
        RoomBean roomBean = new RoomBean();
        roomBean.setId(roomId);
        facilityBean.setRoomBean(roomBean);
        facilityService.add(facilityBean);
        return "ok";
    }

    @RequestMapping("update")
    public String update(Integer id, Integer roomId) {
        facilityService.update(id, roomId);
        return "ok";
    }

    @RequestMapping("findByRoomId")
    public List<FacilityBean> findByRoomId(Integer roomId) {

        return facilityService.findByRoomId(roomId);
    }


}
